﻿using System;
using System.IO;

namespace Common
{
    //系统配置
    public  class SystemConfig
    {
        //数据库Ip地址
        public static  string DbIP = "";
        //数据库用户名
        public static  string DbLoginName = "";
        //数据库密码
        public static  string DbPassword = "";
        //入口摄像头IP地址
        public static  string InCameraIP = "";
        //入口摄像头端口
        public static  string InCameraPort = "";
        //入口摄像头登录名
        public static  string InCameraLoginName = "";
        //入口摄像头登录密码
        public static  string InCameraPassword = "";
        //出口摄像头IP地址
        public static  string OutCameraIP = "";
        //出口摄像头端口
        public static  string OutCameraPort = "";
        //出口摄像头登录名
        public static  string OutCameraLoginName = "";
        //出口摄像头登录密码
        public static  string OutCameraPassword = "";
        //出入口位置
        public static  string PassPlace = "";
        //驶入语音提示
        public static  string IsPassInVoice = "";
        //驶入语音提示内容
        public static  string PassInVoiceText = "";
        //驶出语音提示
        public static  string IsPassOutVoice = "";
        //驶出语音提示内容
        public static  string PassOutVoiceText = "";

        //黑名单语音提示内容
        public static  string BlackCarVoiceText = "";
        //尾随车辆语音提示内容
        public static  string FollowCarVoiceText = "";
        //无进入记录语音提示内容
        public static  string NoPassInRecordVoiceText = "";

        //继电器IP地址
        public static  string RelayIP = "";
        //继电器端口
        public static  string RelayPort = "";
        //道闸开关状态信号
        public static  string GateStatus = "";
        //入口地感线圈状态信号
        public static  string InInductionCoilStatus = "";
        //出口地感线圈状态信号
        public static  string OutInductionCoilStatus = "";
        //道闸开关控制信号
        public static  string GateSwitch = "";
        //报警器控制信号
        public static  string WarnSwitch = "";
        //入口信号灯开关信号
        public static  string InLightSwitch = "";
        //出口信号灯开关信号
        public static  string OutLightSwitch = "";

        //驶入图片保存地址
        public static  string InPicturePath = "";
        //驶出图片保存地址
        public static  string OutPicturePath = "";
        //报警文件地址
        public static  string WarnFilePath = "";

        static SystemConfig()
        {
            if (File.Exists(System.Environment.CurrentDirectory + "/system.ini"))
            {
                WinAPI winAPI = new WinAPI(System.Environment.CurrentDirectory + "/system.ini");
                DbIP = winAPI.ReadValue("DeviceConf", "DbIP");
                DbLoginName = winAPI.ReadValue("DeviceConf", "DbLoginName");
                DbPassword = winAPI.ReadValue("DeviceConf", "DbPassword");

                InCameraIP = winAPI.ReadValue("DeviceConf", "InCameraIP");
                InCameraPort = winAPI.ReadValue("DeviceConf", "InCameraPort");
                InCameraLoginName = winAPI.ReadValue("DeviceConf", "InCameraLoginName");
                InCameraPassword = winAPI.ReadValue("DeviceConf", "InCameraPassword");
                OutCameraIP = winAPI.ReadValue("DeviceConf", "OutCameraIP");
                OutCameraPort = winAPI.ReadValue("DeviceConf", "OutCameraPort");
                OutCameraLoginName = winAPI.ReadValue("DeviceConf", "OutCameraLoginName");
                OutCameraPassword = winAPI.ReadValue("DeviceConf", "OutCameraPassword");

                PassPlace = winAPI.ReadValue("DeviceConf", "PassPlace");
                IsPassInVoice = winAPI.ReadValue("DeviceConf", "IsPassInVoice");
                PassInVoiceText = winAPI.ReadValue("DeviceConf", "PassInVoiceText");
                IsPassOutVoice = winAPI.ReadValue("DeviceConf", "IsPassOutVoice");
                PassOutVoiceText = winAPI.ReadValue("DeviceConf", "PassOutVoiceText");

                BlackCarVoiceText = winAPI.ReadValue("DeviceConf", "BlackCarVoiceText");
                FollowCarVoiceText = winAPI.ReadValue("DeviceConf", "FollowCarVoiceText");
                NoPassInRecordVoiceText = winAPI.ReadValue("DeviceConf", "NoPassInRecordVoiceText");

                InPicturePath = winAPI.ReadValue("FilePath", "InPicturePath");
                OutPicturePath = winAPI.ReadValue("FilePath", "OutPicturePath");
                WarnFilePath = winAPI.ReadValue("FilePath", "WarnFilePath");

                //继电器与网络接口
                RelayIP = winAPI.ReadValue("RelayConf", "RelayIP");
                RelayPort = winAPI.ReadValue("RelayConf", "RelayPort");
                GateStatus = winAPI.ReadValue("RelayConf", "GateStatus");
                InInductionCoilStatus = winAPI.ReadValue("RelayConf", "InInductionCoilStatus");
                OutInductionCoilStatus = winAPI.ReadValue("RelayConf", "OutInductionCoilStatus");
                GateSwitch = winAPI.ReadValue("RelayConf", "GateSwitch");
                WarnSwitch = winAPI.ReadValue("RelayConf", "WarnSwitch");
                InLightSwitch = winAPI.ReadValue("RelayConf", "InLightSwitch");
                OutLightSwitch = winAPI.ReadValue("RelayConf", "OutLightSwitch");
            }
            else
            {
                throw new Exception("系统配置文件不存在！");
            }
        }
    }
}
